const obj = {
    name: "ran",
    age: 18
}

function foo() {
    console.log("foo:", obj.name);
    console.log("foo:", obj.age);
}
function bar() {
    console.log(obj.name + "hello");
    console.log(obj.age + 10);
}
const reactiveFns = []
// 封装一个存放响应式的函数
function watchFn(fn) {
    reactiveFns.push(fn)
    fn()
}
watchFn(function foo() {
    console.log("foo:", obj.name);
    console.log("foo:", obj.age);
    console.log("foo function",);
})

watchFn(function bar() {
    console.log("bar:", obj.name);
    console.log("bar:", obj.age);
    console.log("bar function",);
})
console.log("name发生变化-------------");
obj.name = "kobe"
reactiveFns.forEach(fn => {
    fn()
})